<style lang="scss" scoped>
.form-box {
  padding: 20rpx;
  box-sizing: border-box;

  .form-item-box {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }
}

.btn {
  padding: 30rpx 0;
  box-sizing: border-box;
}
</style>
<template>
  <!-- 表单 -->
  <view class="form-box">
    <q-navbar title="扫码结果" :isBack="false"></q-navbar>
    <u-form ref="form">
      <u-form-item :label="type=='ck'?'出库品类':'入口品类'" prop="categoryName" label-width="auto">
        <view class="form-item-box">
          {{ form.categoryName }}
        </view>
      </u-form-item>
      <u-form-item label="商品名称" prop="merchandiseName" label-width="auto">
        <view class="form-item-box">
          {{ form.merchandiseName }}
        </view>
      </u-form-item>
      <u-form-item :label="type=='ck'?'出库数量(吨)':'入库数量(吨)'" prop="managementCapacity" label-width="auto">
        <view class="form-item-box">
          {{ form.managementCapacity }}
        </view>
      </u-form-item>
      <u-form-item :label="type=='ck'?'最大出库量':'实际入库数量'" prop="realityManagementCapacity" label-width="auto">
        <view class="form-item-box">
          {{ type == 'ck' ? totalNum : form.realityManagementCapacity }}
        </view>
      </u-form-item>
      <u-form-item v-if="type == 'ck'" label="费用" prop="commodityAddress" label-width="auto">
        <view class="form-item-box">
          {{ form.amount || 0 }}元
        </view>
      </u-form-item>
      <u-form-item :label="type=='ck'?'出库仓库':'入库仓库'" prop="warehouseName" label-width="auto">
        <view class="form-item-box">
          {{ form.warehouseName }}
        </view>
      </u-form-item>
      <u-form-item label="库位" prop="commodityAddress" label-width="auto">
        <view class="form-item-box">
          {{ form.commodityAddress }}
        </view>
      </u-form-item>
      <u-form-item label="绑定合同" prop="contractName" label-width="auto">
        <view class="form-item-box">
          {{ form.contractName }}
        </view>
      </u-form-item>
      <u-form-item label="货主姓名" prop="contacts" label-width="auto">
        <view class="form-item-box">
          {{ form.contacts }}
        </view>
      </u-form-item>
      <u-form-item label="货主电话" prop="phone" label-width="auto">
        <view class="form-item-box">
          {{ form.phone }}
        </view>
      </u-form-item>
      <u-form-item v-if="type=='ck'" label="租赁合同名称" prop="contractName">
        <view class="form-item-box">
          {{ hetongDetal.contractName }}
        </view>
      </u-form-item>
      <u-form-item v-if="type=='ck'" label="租赁开始日期" prop="startTime">
        <view class="form-item-box">
          {{ hetongDetal.startTime }}
        </view>
      </u-form-item>
      <u-form-item v-if="type=='ck'" label="租赁结束日期" prop="endTime">

        <view class="form-item-box">
          {{ hetongDetal.endTime }}
        </view>
      </u-form-item>
      <u-form-item v-if="type=='ck'" label="租赁方式" prop="leaseType">
        <view class="form-item-box">
          <q-dict-tag :value="hetongDetal.leaseType" :options="dict.type.zulinfangshi"/>
        </view>
      </u-form-item>
      <u-form-item label="包仓计费规格" prop="packageBillingSpec" v-if="hetongDetal.leaseType==1">
        <view class="form-item-box">
          每天
        </view>
      </u-form-item>
      <u-form-item label="包仓价格(元)" prop="packagePrice" v-if="hetongDetal.leaseType==1">
        <view class="form-item-box">
          {{ hetongDetal.packagePrice }}
        </view>
      </u-form-item>
      <u-form-item label="零仓计费规格" prop="zeroWarehouseSpec" v-if="hetongDetal.leaseType==2">
        <view class="form-item-box">
          每吨
        </view>
      </u-form-item>
      <u-form-item label="零仓价格(元)" prop="zeroWarehousePrice" v-if="hetongDetal.leaseType==2">
        <view class="form-item-box">
          {{ hetongDetal.zeroWarehousePrice }}
        </view>
      </u-form-item>
      <u-form-item :label="type=='ck'?'出库人员':'入库人员'" prop="userName" label-width="auto">
        <view class="form-item-box">
          {{ form.userName }}
        </view>
      </u-form-item>
      <u-form-item :label="type=='ck'?'出库电话':'入库电话'" prop="userPhone" label-width="auto">
        <view class="form-item-box">
          {{ form.userPhone }}
        </view>
      </u-form-item>
      <u-form-item label="备注" prop="remark" label-width="auto">
        <view class="form-item-box">
          {{ form.remark }}
        </view>
      </u-form-item>
    </u-form>
  </view>
</template>


<script>


export default {
  components: {},
  props: {},
  dicts: ['zulinfangshi'],
  data() {
    return {
      form: {},
      hetongDetal: {},
      totalNum: 0,
      type: 'rk'
    }
  },
  watch: {},
  // 必须要在onReady生命周期，因为onLoad生命周期组件可能尚未创建完毕
  onReady() {
  },
  onLoad(options) {
    if (options.id) {
      this.getDetail(options.id)
    }
    if (options.type == 'ck') {
      this.type = 'ck'
    } else {
      this.type = 'rk'
    }
  },
  onShow() {
  },
  methods: {
    getDetail(id) {
      this.$api.getManagement({id}).then(async res => {
        let ret = await this.$api.listWarehouseLeaseRecord({warehouseId: res.data.warehouseId, pageSize: 99999})
        if (!!ret.rows.length) {
          this.form.contractName = ret.rows.find(item => item.id == res.data.hetongId).contractName
        }
        this.form = Object.assign(res.data, this.form)
        console.log('  this.form', this.form)
        if (this.type == 'ck') {
          let res = await this.$api.getWarehouseLeaseRecord(this.form.hetongId)
          console.log('res', res)
          this.hetongDetal = res.data
          let req = await this.$api.getWarehouseStock({
            merchandiseId: this.form.merchandiseId,
            warehouseId: this.form.warehouseId,
            commodityAddress: this.form.commodityAddress,
            contacts: this.form.contacts,
            phone: this.form.phone,
            managementId: this.form.managementId,
          })
          console.log('req', req)
          this.totalNum = req.data
        }
      })
    },
  }
}
</script>
